<!DOCTYPE html>
<html lang="en">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8">
    
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>${_title}</title>

    <!-- Bootstrap core CSS -->

    <link href="${_css}/bootstrap.min.css" rel="stylesheet">

    <link href="${_font}/css/font-awesome.min.css" rel="stylesheet">
    <link href="${_css}/animate.min.css" rel="stylesheet">

    <!-- Custom styling plus plugins -->
    <link href="${_css}/custom.css" rel="stylesheet">
    <link href="${_css}/icheck/flat/green.css" rel="stylesheet">
    <link href="${_css}/datatables/tools/css/dataTables.tableTools.css" rel="stylesheet">
	<link rel="stylesheet" href="${_css}/base.css">
    <script src="${_js}/jquery.min.js"></script>
	<script type="text/javascript" src="${_js}/common.js"></script>
	<script src="${_js}/resize.js"></script>
	<script type="text/javascript" src="${_front_js}/jquery.page.js"></script>
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
          <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
          <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
        <![endif]-->
	<style>
		td a{
			cursor:pointer
		}
		
		#export{
    		color: #fff;
    		background-color: #1A82C3;
    		border-color: #1A82C3;
		}
	</style>
</head>


<body style="background: #F7F7F7;">
<div class="">
    <div class="row">
        <div class="col-md-12 col-sm-12 col-xs-12">
            <div class="x_panel">
	            <div class="x_title">
					<h2>投资列表</h2>
					<div class="clearfix"></div>
				</div>
                <div class="pull-right">
                	<button id="query" type="button" class="btn btn-info">查询</button>
                	<button id="export" type="button" class="btn" >导出</button>
                </div>
                <form class="form-horizontal form-label-left input_mask" id="tenderForm">
                    <div class="col-md-2 col-sm-2 col-xs-3 form-group has-feedback">
                        <select class="form-control" id="status" name="status">
                        	<option value="" <#if !status?exists>selected="selected"</#if>>--所有--</option>
							<option value="borrow" <#if status?exists & status=='borrow'>selected="selected"</#if>>投资中</option>
							<option value="check" <#if status?exists & status=='check'>selected="selected"</#if>>复审中</option>
							<option value="expire" <#if status?exists & status=='expire'>selected="selected"</#if>>已过期/流标</option>
							<option value="pay" <#if status?exists & status=='pay'>selected="selected"</#if>>还款中</option>
							<option value="complete" <#if status?exists & status=='complete'>selected="selected"</#if>>已还完</option>
						</select>
                    </div>
                    <div class="col-md-2 col-sm-2 col-xs-5 form-group has-feedback">
                        <input type="text" class="form-control has-feedback-left" id="matchInviteUser" name="matchInviteUser" 
                        value="<#if matchInviteUser?exists>${matchInviteUser}</#if>"
                        placeholder="输入客户经理">
                        <span class="fa fa-user form-control-feedback left" aria-hidden="true"></span>
                    </div>
                    <div class="col-md-2 col-sm-2 col-xs-6 form-group has-feedback">
                        <input type="text" class="form-control has-feedback-left" id="borrowCode" name="borrowCode" 
                        value="<#if borrowCode?exists>${borrowCode}</#if>"
                        placeholder="输入借款标编号">
                    </div>
                    <div class="col-md-2 col-sm-2 col-xs-6 form-group has-feedback">
                        <input type="text" class="form-control has-feedback-left" id="tenderUserName"  name="tenderUserName"
                        value="<#if tenderUserName?exists>${tenderUserName}</#if>"
                        placeholder="输入投资用户名">
                        <span class="fa fa-user form-control-feedback left" aria-hidden="true"></span>
                    </div>
                    <form class="form-horizontal">
						<fieldset>
							<div class="control-group">
								<div class="controls">
									<div class="input-prepend input-group">
										<span class="add-on input-group-addon">
											<i class="glyphicon glyphicon-calendar fa fa-calendar"></i>
										</span>
										<input type="text" style="width: 200px" name="tenderTime" id="reservation" placeholder="请选择投资时间段"
										class="form-control" value="" />
									</div>
								</div>
							</div>
						</fieldset>
					</form>
                 </form>
                <div class="clearfix"></div>
            </div>
            <div class="scroll">
                <div class="x_content">
                    <table id="example" data-action="/admin/tender/list?1=1" class="table table-striped responsive-utilities jambo_table">
                        <thead>
                            <tr class="headings">
	                            <th>
	                                <input type="checkbox" class="tableflat">
	                            </th>
                                <th>编号 </th>
                                <th>借款标题 </th>
                                <th>年化率</th>
                                <th>奖励年化率</th>
                                <th>期限</th>
                                <th>投资用户名 </th>
                                <th>贷款编号</th>
                                <th>投标金额</th>
                                <th>投标时间</th>
                                <th>投标方式</th>
                            </tr>
                        </thead>
                        <tbody>
			                <#if (pageInfo.pageList?size > 0)>
								<#list pageInfo.pageList as model>
									<tr class="even pointer">
		                                <td class="a-center ">
		                                    <input type="checkbox" class="tableflat" data-id="${model.id}">
		                                </td>
		                                <td>
		                                	<#if model.id??>
			                                	${model.id}
		                                	</#if>
		                                </td>
		                                <td>
		                                	<#if model.title??>
			                                	${model.title}
		                                	</#if>
		                                </td>
		                                <td>
		                                	<#if model.percent??>
		                                		${model.percent?string('0.00')}%
		                                	</#if>
		                                </td>
		                                <td>
		                                	<#if model.rewardPercent??>
		                                		${model.rewardPercent?string('0.00')}%
		                                	<#else>
		                                		0.00%
		                                	</#if>
		                                </td>
		                                <td>
		                                	<#if model.deadline?exists>
					                            ${model.deadline}
					                            <#if model.dateUtil?exists>
			                                		<#if model.dateUtil == "MONTH">
														个月
														<#elseif model.dateUtil == "DAY">
														天
														<#elseif model.dateUtil == "YEAR">
														年
													</#if>
												</#if>
				                            </#if>
		                                </td>
		                                <td>
		                                	<#if model.tenderUserName??>
			                                	${model.tenderUserName}
		                                	</#if>
		                                </td>
		                                <td>
		                                	暂无
		                                	<#if model.borrowCode??>
		                                		${model.borrowCode}
		                                	</#if>
		                                </td>
		                                <td>
		                                	<#if model.amount??>
		                                		${model.amount?string('0.00')}
		                                	</#if> 
		                                </td>			
		                                <td>
		                                	<#if model.createTime??>
		                                		${(model.createTime?string("yyyy-MM-dd HH:mm:ss"))}	
		                                	</#if>                                	
		                                </td>
		                                <td>
		                                	<#if model.isAuto??>
		                                		<#if model.isAuto=='Y'>
		                                			自动
		                                		<#elseif model.isAuto=='N'>
		                                			手动
		                                		</#if>
		                                	</#if>                                	
		                                </td>
		                             </tr>   
		                        </#list>
								<#else>
								<tr class="even pointer">
									<td colspan="11">无记录</td>
								</tr>
							</#if>
                        </tbody>
                    </table>
                    <#if (pageInfo.pageList?size > 0)>
	                	<#include "../base/Page.ftl">
	                </#if>
	                <div id="pageCollect">
	                	<#if (pageInfo.pageList?size > 0)>
							共计：<span style="color:#1ABB9C">${pageInfo.total}</span>笔，
							投资总额：<span style="color:#1ABB9C">${pageInfo.sum?string('0.00')}</span>元
		                </#if>
	                </div>
                </div>
            </div>
        </div>
        <br />
        <br />
        <br />
    </div>
</div>
                    
<script src="${_js}/bootstrap.min.js"></script>

<!-- bootstrap progress js -->
<script src="${_js}/progressbar/bootstrap-progressbar.min.js" type="text/javascript"></script>
<script src="${_js}/nicescroll/jquery.nicescroll.min.js" type="text/javascript"></script>
<!-- icheck -->
<script src="${_js}/icheck/icheck.min.js" type="text/javascript"></script>

<script src="${_js}/custom.js" type="text/javascript"></script>

<!-- PNotify -->
<script src="${_js}/notify/pnotify.core.js" type="text/javascript"></script>
<script src="${_js}/notify/pnotify.buttons.js" type="text/javascript"></script>
<script src="${_js}/notify/pnotify.nonblock.js" type="text/javascript" ></script>
<!-- daterangepicker -->
<script type="text/javascript" src="${_js}/datepicker/moment.min2.js"></script>
<script type="text/javascript" src="${_js}/datepicker/daterangepicker.js"></script>
<script type="text/javascript" src="${_front_js}/date.js"></script>

<script>
    $(document).ready(function () {
        $('input.tableflat').iCheck({
            checkboxClass: 'icheckbox_flat-green',
            radioClass: 'iradio_flat-green'
        });
        
        $('#reservation').daterangepicker(null, function (start, end, label) {
            //console.log(start.toISOString(), end.toISOString(), label);
        });
    });
</script>
<script>
	
	function initData(action) { 
		var status = $("#status").find("option:selected").val();
		var matchInviteUser = $.trim($("#matchInviteUser").val());
		var borrowCode = $.trim($("#borrowCode").val());
		var tenderUserName = $.trim($("#tenderUserName").val());
    	var reservation = $("#reservation").val();
    	var reg = /^\d{4}[-]\d{2}[-]\d{2}~\d{4}[-]\d{2}[-]\d{2}$/;
    	if(reservation !="" && !reg.test(reservation)){
			new PNotify({
		            	title: '操作提示',
		            	text: '时间格式错误！',
		            	delay: 3e3,
		            	type: 'error'
		        	});
		    return false;
		}
		if(status != ""){
    		action += "&status="+status;
    	}
    	if(matchInviteUser != ""){
    		action += "&matchInviteUser="+matchInviteUser;
    	}
    	if(borrowCode != ""){
    		action += "&borrowCode="+borrowCode;
    	}
    	if(tenderUserName != ""){
    		action += "&tenderUserName="+tenderUserName;
    	}
    	if(reservation !=""){
    		var splitChar = "~";
    		if(reservation.indexOf(splitChar) != -1){
    			var timeBegin = $.trim(reservation.split(splitChar)[0]);
    			var timeEnd = $.trim(reservation.split(splitChar)[1]);
    			action +="&timeBegin="+timeBegin;
    			action +="&timeEnd="+timeEnd;
    		}
    	}
		window.location.href=encodeURI(encodeURI(action));

	} 
	
	$("#export").click(function(){
		var count=0;
		var ids=new Array();
		var status = "";
		$("tbody .tableflat").each(function(){
			if($(this).parent().hasClass('checked')){
				ids[count]=$(this).attr("data-id");
				count++;
			}
		})
    	var reservation = $("#reservation").val();
    	var reg = /^\d{4}[-]\d{2}[-]\d{2}~\d{4}[-]\d{2}[-]\d{2}$/;
    	if(reservation !="" && !reg.test(reservation)){
			new PNotify({
		            	title: '操作提示',
		            	text: '时间格式错误！',
		            	delay: 3e3,
		            	type: 'error'
		        	});
		    return false;
		}
		var action="/admin/export/tender?ids="+ids;
		
		$("#tenderForm").attr("method","post");
		$("#tenderForm").attr("action",action);
		$("#tenderForm").submit();
	});	
	
	$(".btn-info").click(function(){
		initData($("#example").attr('data-action'));
	});
	
</script>

 <script language="javascript" type="text/javascript">  
    $(function () {  
		$('.headings input').on('ifChecked', function(event){
		  $("tbody :checkbox").iCheck('check');
		});

		$('.headings input').on('ifUnchecked', function(event){
		  $("tbody :checkbox").iCheck('uncheck');
		});
    });  
    
    var timeBegin = "<#if timeBegin?exists>${timeBegin}</#if>";
	var timeEnd = "<#if timeEnd?exists>${timeEnd}</#if>";
	if(timeBegin != "" && timeEnd != ""){
		document.getElementById("reservation").value=timeBegin+"~"+timeEnd
	}
</script> 
</body>

</html>